package com.goodmean.login;


import com.goodmean.common.model.Student;
import com.goodmean.common.model.Teacher;
import com.goodmean.student.StudentService;
import com.goodmean.teacher.teacher.TeacherService;

import com.jfinal.kit.StrKit;


public class LoginService {
    public static final LoginService me = new LoginService();
    private StudentService studentService = StudentService.me;
    private TeacherService teacherService = TeacherService.me;

    public int login(String loginName, String password) {

            Student student = studentService.findByid(loginName);
            if (student == null) {
                Teacher teacher = teacherService.findById(Integer.valueOf(loginName));
                if (teacher == null) {
                    return -1;
                }
                if (password.equals(teacher.getTeacherPassword())) {
                    return teacher.getTeacherJurisdiction();
                }
            } else {
                if (password.equals(student.getStudentPassword())) {
                    return 3;
                }
            }

        return -1;
    }

}
